﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Xml.Serialization;
using System.IO;

namespace ParticleSystem
{
    [Serializable]
    public class RFBase
    {
        public string Thumbnail = "";
        public string Export = "";
        public string XmlType = "Particle Effect";
        public string XmlEditor = "ParticleEditor";

        public static Emitter load(string filename, Type type)
        {
            StreamReader reader = File.OpenText(filename);

            XmlSerializer xs = new System.Xml.Serialization.XmlSerializer(type);
            Emitter rfbase = (Emitter)xs.Deserialize(reader);
            reader.Close();

            rfbase.EmitterInit();
            rfbase.ParticlesInit();

            return rfbase;
        }

        public static void save(Emitter rfbase, string filename)
        {
            XmlSerializer xs = new XmlSerializer(rfbase.GetType());// typeof( RFBase ) );

            StreamWriter writer = File.CreateText(filename);
            xs.Serialize(writer, rfbase);
            writer.Close();
        }

    }

}
